<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const zhangsan = {
      name: '张三',
      sayHi() {
        //this指当前对象
        console.log(this);
      },
      wait() {
        setTimeout(function() {
          //this指向window
          console.log(this);
        })
      },
      waitAgain() {
        setTimeout(() => {
          //箭头函数中this取值是上级作用域的值
          //this指向当前对象
          console.log(this);
        })
      }
    }
    zhangsan.sayHi();
    zhangsan.wait();
    zhangsan.waitAgain();
</script>
</body>
</html>
